package my.study.java.lang.Class.examples;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;

import my.study.java.lang.Class.examples.basic.MyList;

public class Introduction {

	/**
	 * @param args
	 * @throws IOException
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		//init
		/*
		Class<? extends Number> c1 = int.class;
		Class<?> c2 = Integer.class;
		Class<?> c3 = Integer.TYPE;
		Class<?> c4 = Class.forName("java.lang.Integer");
		*/
		Class<?> arraylist = ArrayList.class;

		pl("if MyList is an instance of this class\n"
				+ "arraylist.isInstance(new MyList<String>())\t"
				+ arraylist.isInstance(new MyList<String>()));
		pl("whether MyList of the type can be assigned to objects of this class\n"
				+ "arraylist.isAssignableFrom(MyList.class)\t"
				+ arraylist.isAssignableFrom(MyList.class));
		pl("if this object represents an interface\n"
				+ "arraylist.isInterface()\t"
				+ arraylist.isInterface());
		pl("if this object represents an array class\n"
				+ "arraylist.isArray()\t"
				+ arraylist.isArray());
		pl("if this class is a local class\n"
				+ "arraylist.isLocalClass()\t"
				+ arraylist.isLocalClass());
		pl("the name of the class or interface represented by this object\n"
				+ "arraylist.getName()\t"
				+ arraylist.getName());
		pl("the immediately enclosing class of the underlying class\n"
				+ "arraylist.getEnclosingClass()\t"
				+ arraylist.getEnclosingClass());
		pl("the canonical name of the underlying class\n"
				+ "arraylist.getCanonicalName()\t"
				+ arraylist.getCanonicalName());
		
		pl("the array of Field objects representing all the declared fields of this class\n"
				+ "arraylist.getDeclaredFields()");
		
		for (Field field : arraylist.getDeclaredFields()) {
			pl(field);
		}
		for (Constructor<?> con : arraylist.getDeclaredConstructors()) {
			pl(con);
		}
		for (Class<?> cl : arraylist.getInterfaces()) {
			pl(cl);
		}
		
		

		
	}

	public static void pl(Object o) {
		System.out.println(o);
	}

}
